<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="12" :lg="12" :md="12" :sm="24">
            <a-form-item label="创建日期">
              <j-date
                :show-time="true"
                date-format="YYYY-MM-DD"
                placeholder="请选择开始时间"
                class="query-group-cust"
                v-model="queryParam.createTime_begin"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                :show-time="true"
                date-format="YYYY-MM-DD"
                placeholder="请选择结束时间"
                class="query-group-cust"
                v-model="queryParam.createTime_end"
              ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd"  v-if="activeKey==='notGenerated'" type="primary" icon="plus">新增</a-button>
      <a-button @click="handleOrderDetailList" v-if="activeKey==='notGenerated'"  type="primary" icon="plus">订单明细</a-button>
      <a-button @click="handleDetailList" v-if="activeKey==='notGenerated'"  type="primary" icon="plus">收货明细</a-button>
      <a-button @click="handleAdjustment" v-if="activeKey==='notGenerated'"  type="primary" icon="plus">费用调整</a-button>
      <!-- 高级查询区域 -->
<!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-tabs v-model="activeKey" @change="handleChangeTab">
        <a-tab-pane key="notGenerated" tab="未生成">
          <a-row :gutter="10">
            <a-col :span="24">
              <a-card>
                <a-card :bordered="false">
                  <a-table
                  ref="table"
                  size="middle"
                  bordered
                  :rowKey="
              (record, index) => {
                return record.orderId
              }
            "
                  class="j-table-force-nowrap"
                  :scroll="{x:true}"
                  :columns="columns"
                  :dataSource="dataSource"
                  :pagination="ipagination"
                  :loading="loading"
                  :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: handleSelectChange,type:'radio'}"
                  :customRow="clickThenSelect"
                  @change="handleTableChange">

                  <template slot="htmlSlot" slot-scope="text">
                    <div v-html="text"></div>
                  </template>
                  <template slot="imgSlot" slot-scope="text,record">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                    <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
                  </template>
                  <template slot="fileSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                    <a-button
                      v-else
                      :ghost="true"
                      type="primary"
                      icon="download"
                      size="small"
                      @click="downloadFile(text)">
                      下载
                    </a-button>
                  </template>

                  <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

                </a-table>
                </a-card>
              </a-card>
            </a-col>
          </a-row>
          <a-col :span="24">
            <a-card :bordered="false">
              <a-tabs defaultActiveKey="1">
                <a-tab-pane tab="回款信息" key="1">
                  <a-table
                    ref="table"
                    size="middle"
                    bordered
                    rowKey="id"
                    class="j-table-force-nowrap1"
                    :scroll="{x:true}"
                    :columns="detail.columns"
                    :dataSource="detail.dataSource"
                    :rowSelection="{selectedRowKeys: detail.selectedRowKeys, onChange: onSelectDetailChange}"
                    :loading="loading">
                    <template slot="fileSlot" slot-scope="text">
                      <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                      <div v-else>
                        <a-button
                          :ghost="true"
                          type="primary"
                          icon="download"
                          size="small"
                          @click="downloadFile(text)"
                          style="margin-right: 8px;">
                          下载
                        </a-button>
                        <a-button
                          :ghost="true"
                          type="primary"
                          icon="eye"
                          size="small"
                          @click="handlePreviewFile(text)">
                          预览
                        </a-button>
                      </div>
                    </template>
                  </a-table>
                </a-tab-pane>
              </a-tabs>
            </a-card>
          </a-col>
        </a-tab-pane>
        <a-tab-pane key="temporarySave" tab="暂存中">
          <a-table
            ref="needCreateTable"
            size="middle"
            bordered
            rowKey="id"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="approvalColumns"
            :dataSource="temporarySave.dataSource"
            :pagination="temporarySave.ipagination"
            :loading="temporarySave.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)">编辑</a>
              <a-divider type="vertical"></a-divider>
              <act-apply-btn
                v-show="record.status < 0"
                @success="loadData"
                :data-id="record.id"
                :serviceName="serviceName"
                :variables="record"
              ></act-apply-btn>
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="needEdit" tab="需修改">
          <a-table
            ref="needEditTable"
            size="middle"
            bordered
            rowKey="id"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="approvalColumns"
            :dataSource="needEditTable.dataSource"
            :pagination="needEditTable.ipagination"
            :loading="needEditTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <a v-if="record.status < 0" @click="handleEdit(record)">编辑</a>
              <a-divider type="vertical"></a-divider>
              <act-apply-btn
                v-show="record.actStatus == '撤回'"
                @success="loadData"
                :data-id="record.id"
                :serviceName="serviceName"
                :variables="record"
              ></act-apply-btn>
              <a v-if="record.actStatus != '撤回'" @click="handleStop(record)">取消申请</a>
              <a-divider v-if="record.actStatus != '撤回'" type="vertical" />
              <a v-if="record.actStatus !='撤回'" @click="handleProcess(record)">提交</a>
              <a-divider v-if="record.actStatus != '撤回'" type="vertical" />
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="approving" tab="审批中">
          <a-table
            ref="approvingTable"
            size="middle"
            bordered
            rowKey="id"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns"
            :dataSource="approvingTable.dataSource"
            :pagination="approvingTable.ipagination"
            :loading="approvingTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a v-if="record.actStatus != '撤回'" @click="handleStop(record)">取消申请</a>
                  </a-menu-item>
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="approved" tab="已审批">
          <a-table
            ref="approvedTable"
            size="middle"
            bordered
            rowKey="id"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns"
            :dataSource="approvedTable.dataSource"
            :pagination="approvedTable.ipagination"
            :loading="approvedTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
      </a-tabs>
    </div>

    <sales-collection-management-modal ref="modalForm" @ok="modalFormOk"/>
    <SalesCollectionManagementOrderDetailModal ref="orderDetail"></SalesCollectionManagementOrderDetailModal>
    <SalesCollectionManagementDetailModal ref="detail"></SalesCollectionManagementDetailModal>
    <SalesCollectionManagementAdjustmentModal ref="adjustment" @ok="modalFormOk"></SalesCollectionManagementAdjustmentModal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import SalesCollectionManagementModal from './modules/SalesCollectionManagementModal'
  import '@/assets/less/TableExpand.less'
  import ActHistoricDetailBtn from '@views/flowable/components/ActHistoricDetailBtn.vue'
  import ActApplyBtn from '@views/flowable/components/ActApplyBtn.vue'
  import { getAction } from '@api/manage'
  import TicketCollectionManagementOrderDetailModal
    from '@views/business/procurement/modules/TicketCollectionManagementOrderDetailModal.vue'
  import TicketCollectionManagementDetailModal
    from '@views/business/procurement/modules/TicketCollectionManagementDetailModal.vue'
  import SalesCollectionManagementOrderDetailModal
    from '@views/business/procurement/modules/SalesCollectionManagementOrderDetailModal.vue'
  import SalesCollectionManagementDetailModal
    from '@views/business/procurement/modules/SalesCollectionManagementDetailModal.vue'
  import SalesCollectionManagementAdjustmentModal
    from '@views/business/procurement/modules/SalesCollectionManagementAdjustmentModal.vue'

  export default {
    name: "SalesCollectionManagementList",
    mixins:[JeecgListMixin],
    components: {
      SalesCollectionManagementAdjustmentModal,
      SalesCollectionManagementDetailModal,
      SalesCollectionManagementOrderDetailModal,
      TicketCollectionManagementDetailModal, TicketCollectionManagementOrderDetailModal,
      ActApplyBtn, ActHistoricDetailBtn,
      SalesCollectionManagementModal
    },
    data () {
      return {
        description: '销售回款管理管理页面',
        activeKey: 'notGenerated',
        serviceName: 'salesCollectionManagementService',
        ipagination: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        detail:{
          selectedRowKeys: [],
          selectionRows:[],
          dataSource:[],
          ipagination: {
            current: 1,
            pageSize: 10,
            pageSizeOptions: ['10', '30', '100'],
            showTotal: (total, range) => {
              return range[0] + '-' + range[1] + ' 共' + total + '条'
            },
            showQuickJumper: true,
            showSizeChanger: true,
            total: 0,
          },
          columns: [
            {
              title: '#',
              dataIndex: '',
              key:'rowIndex',
              width:60,
              align:"center",
              customRender:function (t,r,index) {
                return parseInt(index)+1;
              }
            },
            {
              title:'订单编号',
              align:"center",
              dataIndex: 'schedulingNumber'
            },
            {
              title:'回款金额（支付）',
              align:"center",
              dataIndex: 'nowPayment'
            },
            {
              title:'回款金额（到账）',
              align:"center",
              dataIndex: 'nowDaozhang'
            },
            {
              title:'回款日期',
              align:"center",
              dataIndex: 'paymentDate'
            },
            {
              title:'登记人',
              align:"center",
              dataIndex: 'createBy'
            },
            {
              title:'登记时间',
              align:"center",
              dataIndex: 'createTime',
              customRender:function (text) {
                return !text?"":(text.length>10?text.substr(0,10):text)
              }
            },
            {
              title:'回款备注',
              align:"center",
              dataIndex: 'remark'
            },
          ],
        },
        temporarySave:{
          loading: false,
          dataSource:[],
          columns:[],
          ipagination: {
            current: 1,
            pageSize: 30,
            pageSizeOptions: ['10', '30', '100'],
            showTotal: (total, range) => {
              return range[0] + '-' + range[1] + ' 共' + total + '条'
            },
            showQuickJumper: true,
            showSizeChanger: true,
            total: 0,
          },
        },
        needEditTable:{
          loading: false,
          dataSource:[],
          columns:[],
          ipagination: {
            current: 1,
            pageSize: 30,
            pageSizeOptions: ['10', '30', '100'],
            showTotal: (total, range) => {
              return range[0] + '-' + range[1] + ' 共' + total + '条'
            },
            showQuickJumper: true,
            showSizeChanger: true,
            total: 0,
          },
        },
        approvingTable: {
          loading: false,
          dataSource: [],
          // 表头
          ipagination: {
            current: 1,
            pageSize: 3000,
            pageSizeOptions: ['3000', '200', '500'],
            showTotal: (total, range) => {
              return range[0] + '-' + range[1] + ' 共' + total + '条'
            },
            showQuickJumper: true,
            showSizeChanger: true,
            total: 0,
          },
        },
        approvedTable: {
          loading: false,
          dataSource: [],
          // 表头
          ipagination: {
            current: 1,
            pageSize: 3000,
            pageSizeOptions: ['3000', '200', '500'],
            showTotal: (total, range) => {
              return range[0] + '-' + range[1] + ' 共' + total + '条'
            },
            showQuickJumper: true,
            showSizeChanger: true,
            total: 0,
          },
        },
        approvalColumns:[
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'审批单号',
            align:"center",
            dataIndex: 'approvalCode'
          },
          {
            title:'订单编号',
            align:"center",
            dataIndex: 'schedulingNumber'
          },
          {
            title:'单据类型',
            align:"center",
            dataIndex: 'documentType_dictText'
          },
          {
            title:'销售类型',
            align:"center",
            dataIndex: 'salesType_dictText'
          },
          {
            title:'业务员',
            align:"center",
            dataIndex: 'salesman_dictText'
          },
          {
            title:'客户名称',
            align:"center",
            dataIndex: 'customerName'
          },
          {
            title:'订单数量（吨）',
            align:"center",
            dataIndex: 'orderNum'
          },
          {
            title:'币种',
            align:"center",
            dataIndex: 'moneyUnit_dictText'
          },
          {
            title:'订单金额',
            align:"center",
            dataIndex: 'orderAmount'
          },
          {
            title:'发货金额',
            align:"center",
            dataIndex: 'shipmentAmount'
          },
          {
            title:'其它费用',
            align:"center",
            dataIndex: 'otherExpenses'
          },
          {
            title:'合计金额',
            align:"center",
            dataIndex: 'totalAmount'
          },
          {
            title:'回款金额（支付）',
            align:"center",
            dataIndex: 'nowPayment'
          },
          {
            title:'回款金额（到账）',
            align:"center",
            dataIndex: 'nowDaozhang'
          },
          {
            title:'回款日期',
            align:"center",
            dataIndex: 'paymentDate'
          },
          {
            title:'申请人',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title:'申请部门',
            align:"center",
            dataIndex: 'sysOrgCode'
          },
          {
            title:'申请时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 147,
            scopedSlots: { customRender: 'action' },
          },
        ],
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'订单编号',
            align:"center",
            dataIndex: 'schedulingNumber'
          },
          {
            title:'单据类型',
            align:"center",
            dataIndex: 'documentType_dictText'
          },
          {
            title:'销售类型',
            align:"center",
            dataIndex: 'salesType_dictText'
          },
          {
            title:'业务员',
            align:"center",
            dataIndex: 'salesman_dictText'
          },
          {
            title:'客户名称',
            align:"center",
            dataIndex: 'customerName'
          },
          {
            title:'订单数量（吨）',
            align:"center",
            dataIndex: 'orderNum'
          },
          {
            title:'币种',
            align:"center",
            dataIndex: 'moneyUnit_dictText'
          },
          {
            title:'订单金额',
            align:"center",
            dataIndex: 'orderAmount'
          },
          {
            title:'发货金额',
            align:"center",
            dataIndex: 'shipmentAmount'
          },
          {
            title:'其它费用',
            align:"center",
            dataIndex: 'otherExpenses'
          },
          {
            title:'合计金额',
            align:"center",
            dataIndex: 'totalAmount'
          },
          {
            title:'已回款金额',
            align:"center",
            dataIndex: 'alreadyPayment'
          },
          {
            title:'未回款金额',
            align:"center",
            dataIndex: 'unPayment'
          },
          {
            title:'回款状态',
            align:"center",
            dataIndex: 'collectionStatus_dictText'
          },
          {
            title:'制单人',
            align:"center",
            dataIndex: 'createPerson'
          },
          {
            title:'制单部门',
            align:"center",
            dataIndex: 'createDate'
          },
          {
            title:'制单时间',
            align:"center",
            dataIndex: 'createDate'
          },
        ],
        url: {
          list: "/procurement/salesCollectionManagement/list",
          delete: "/procurement/salesCollectionManagement/delete",
          deleteBatch: "/procurement/salesCollectionManagement/deleteBatch",
          exportXlsUrl: "/procurement/salesCollectionManagement/exportXls",
          importExcelUrl: "procurement/salesCollectionManagement/importExcel",
          approvalList:"procurement/salesCollectionManagement/approvalList"

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.handleChangeTab();
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      clickThenSelect(record){
        return {
          onClick:()=>{
            this.handleSelectChange(record.id.split(","), [record]);
          }
        }
      },
      handleSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
        console.log(this.selectedRowKeys,this.selectionRows)
        this.detail.dataSource=[]
        let ids = selectedRowKeys.join(",")
        console.log("222131",ids)
        getAction('/procurement/salesCollectionManagement/collectionList',
          {orderId:ids}).then(res=>{
          if (res.success){
            this.detail.dataSource=res.result
          }
        })
      },
      handleAdjustment(){
        const row = this.selectionRows
        if(row.length===0){
          return this.$message.warning('请选择一条数据')
        }
        this.$nextTick(() => {
          this.$refs.adjustment.adjustment(row)
        })
      },
      handleOrderDetailList(){
        const row = this.selectionRows
        if(row.length===0){
          return this.$message.warning('请选择一条数据')
        }
        this.$nextTick(() => {
          this.$refs.orderDetail.crmDetail(row)
        })
      },
      handleDetailList(){
        const row = this.selectionRows
        if(row.length===0){
          return this.$message.warning('请选择一条数据')
        }
        this.$nextTick(() => {
          this.$refs.detail.crmDetail(row)
        })
      },
      modalFormOk() {
        // 新增/修改 成功时，重载列表
        this.searchQuery()
        //清空列表选中
        this.onClearSelected()
      },

      searchReset(){
        this.queryParam = [];
        this.handleChangeTab();
      },

      searchQuery() {
        if(typeof this.beforeSearch === 'function'){
          let isreturn = this.beforeSearch()
          if(!isreturn){
            return;
          }
        }
        switch (this.activeKey) {
          case 'notGenerated':
            this.loadNotGeneratedData()
            break
          case 'temporarySave':
            this.loadTempSaveData()
            break
          case 'needEdit':
            this.loadNeedEditData()
            break
          case 'approving':
            this.loadApprovingData()
            break
          case 'approved':
            this.loadApprovedData()
            break
          default:
            break
        }
        //this.loadData(1);
        // 点击查询清空列表选中行
        // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
      },

      // loadData(){
      //   this.handleChangeTab()
      // },
      handleChangeTab() {
        switch (this.activeKey) {
          case 'notGenerated':
            this.loadNotGeneratedData()
            break
          case 'temporarySave':
            this.loadTempSaveData()
            break
          case 'needEdit':
            this.loadNeedEditData()
            break
          case 'approving':
            this.loadApprovingData()
            break
          case 'approved':
            this.loadApprovedData()
            break
          default:
            break
        }
      },
      loadNotGeneratedData() {
        //未生成单据，status=-2
        this.loading = true
        getAction(this.url.list, this.queryParam)
          .then((res) => {
            if (res.success) {
              this.dataSource = res.result.records || res.result
              if (res.result.total) {
                this.ipagination.total = res.result.total
              } else {
                this.ipagination.total = 0
              }
            } else {
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.loading = false
          })
      },
      loadTempSaveData() {
        //暂存中单据，status=-1
        this.queryParam.status = -2
        this.temporarySave.loading = true
        getAction(this.url.approvalList, this.queryParam)
          .then((res) => {
            if (res.success) {
              this.temporarySave.dataSource = res.result.records || res.result
              if (res.result.total) {
                this.temporarySave.ipagination.total = res.result.total
              } else {
                this.temporarySave.ipagination.total = 0
              }
            } else {
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.temporarySave.loading = false
          })
      },
      loadNeedEditData() {
        //需修改单据，status=-1
        this.queryParam.status = -1
        this.needEditTable.loading = true
        getAction(this.url.approvalList, this.queryParam)
          .then((res) => {
            if (res.success) {
              this.needEditTable.dataSource = res.result.records || res.result
              if (res.result.total) {
                this.needEditTable.ipagination.total = res.result.total
              } else {
                this.needEditTable.ipagination.total = 0
              }
            } else {
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.needEditTable.loading = false
          })
      },
      loadApprovingData() {
        //审核中单据，status=0
        this.queryParam.status = 0
        this.approvingTable.loading = true
        getAction(this.url.approvalList, this.queryParam)
          .then((res) => {
            if (res.success) {
              this.approvingTable.dataSource = res.result.records || res.result
              if (res.result.total) {
                this.approvingTable.ipagination.total = res.result.total
              } else {
                this.approvingTable.ipagination.total = 0
              }
            } else {
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.approvingTable.loading = false
          })
      },
      loadApprovedData() {
        //已审核单据，status=999
        this.queryParam.status = 999
        this.approvedTable.loading = true
        getAction(this.url.approvalList, this.queryParam)
          .then((res) => {
            if (res.success) {
              this.approvedTable.dataSource = res.result.records || res.result
              if (res.result.total) {
                this.approvedTable.ipagination.total = res.result.total
              } else {
                this.approvedTable.ipagination.total = 0
              }
            } else {
              this.$message.warning(res.message)
            }
          })
          .finally(() => {
            this.approvedTable.loading = false
          })
      },
      handleAdd(){
        console.log("211111111",this.selectionRows)
        if(this.selectionRows.length===0){
          return this.$message.warning("请选择一条记录")
        }else {
          this.$nextTick(()=>{
            this.$refs.modalForm.add(this.selectionRows);
          })
        }
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'approvalCode',text:'审批单号',dictCode:''})
        fieldList.push({type:'string',value:'approvalType',text:'审批流程',dictCode:'sales_collection_approval'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>